package com.hspedu.homework;

import java.util.Objects;

/**
 * 编写Doctor类{name, age, job, gender, sal}
 * 相应的getter()和setter()方法，5个参数的构造器，
 * 重写父类的equals()方法：public boolean equals(Object obj),
 * 并判断测试类中创建的两个对象是否相等，相等就是判断属性是否相同
 */
public class Homework10 {
    public static void main(String[] args) {
        Doctor doctor1 = new Doctor("张三", 20, "儿科医生", "男", 15000);
        Doctor doctor2 = new Doctor("李四", 20, "儿科医生", "男", 15000);
        System.out.println(doctor1.equals(doctor2));
    }
}
class Doctor{
    private String name;
    private int age;
    private String job;
    private String gender;
    private double sal;

    public Doctor() {
    }

    public Doctor(String name, int age, String job, String gender, double sal) {
        this.name = name;
        this.age = age;
        this.job = job;
        this.gender = gender;
        this.sal = sal;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getJob() {
        return job;
    }

    public void setJob(String job) {
        this.job = job;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    public double getSal() {
        return sal;
    }

    public void setSal(double sal) {
        this.sal = sal;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;//判断两个比较对象是否相同
        if (o == null || getClass() != o.getClass()) return false;
        Doctor doctor = (Doctor) o;
        return age == doctor.age
                && Double.compare(doctor.sal, sal) == 0
                && Objects.equals(name, doctor.name)
                && Objects.equals(job, doctor.job)
                && Objects.equals(gender, doctor.gender);
    }
}